<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function Parent(n){
    this.name = n;
  }
  Parent.prototype.show = function(){
    console.log(this.name)
  }

  function Child(){}
  // 原型对象继承，拷贝原型对象，注意深浅拷贝，注意constructor的指向
  // Child.prototype = Parent.prototype;
  // for(let i in Parent.prototype){
  //   Child.prototype[i] = Parent.prototype[i];
  // }
  Child.prototype = {
    ...Parent.prototype,
    constructor: Child
  };

  Child.prototype.show = function(){
    console.log("hahahha")
  }
  
  const p = new Parent("admin");
  console.log(p);
  p.show();

  const c = new Child("zhangsan");
  console.log(c);
  c.show();

</script>
</html>